package com.hmkj.core.service.banner.impl;

import com.hmkj.common.baseMapper.GenericMapper;
import com.hmkj.core.mapper.banner.BannerMapper;
import com.hmkj.core.po.banner.Banner;
import com.hmkj.core.service.banner.BannerService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 首页轮播图业务相关Service接口实现<br>
 *
 * @ClassName: BannerServiceImpl
 * @author eproo
 * @date   2018-07-09 11:47:34
 */
@Service
@Scope("prototype")
@Transactional(rollbackFor = Exception.class)
public class BannerServiceImpl implements BannerService {

	@Resource
    private BannerMapper bannerMapper;

    @Override
    public GenericMapper<Banner,Integer> _getMapper() {
        return bannerMapper;
    }

    @Override
    public List<Banner> findBannerList(Integer type) throws Exception {
        String whereSql = " and t.del_flag = 1 and is_show = 1 and is_pc = "+type;
        String sortSql = " order by t.sort asc ";
        Map<String, Object> params = new HashMap<>();
        params.put("whereSql", whereSql);
        params.put("sortSql", sortSql);
        return bannerMapper.findBannerListBySql(params);
    }
}
